package com.cskaoyan.service.system;

import com.cskaoyan.bean.common.CommonData;
import com.cskaoyan.bean.po.MarketAdmin;
import com.cskaoyan.bean.po.MarketAdminExample;
import com.cskaoyan.bean.po.MarketLog;
import com.cskaoyan.mapper.MarketLogMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class OperationLogServiceImpl implements OperationLogService{

    @Autowired
    MarketLogMapper mapper;

    @Override
    @Transactional
    public CommonData<MarketLog> selectCommonData(Integer page, Integer limit, String sort, String order, String name) {
        PageHelper.startPage(page, limit);
        List<MarketLog> marketAdmins = mapper.selectLog(name,sort,order);
        CommonData<MarketLog> marketAdminCommonData = new CommonData<>();
        PageInfo<MarketLog> pageInfo = new PageInfo<>(marketAdmins);
        marketAdminCommonData.setLimit(limit);
        marketAdminCommonData.setPage(page);
        marketAdminCommonData.setTotal((int) pageInfo.getTotal());
        marketAdminCommonData.setPages(pageInfo.getPages());
        marketAdminCommonData.setList(pageInfo.getList());
        return marketAdminCommonData;
    }
}
